luci-mod-status: add vendor info in index file
authorChristian Korber <[email protected]>
Tue, 9 Sep 2025 08:51:56 +0000 (10:51 +0200)
committerPaul Donald <[email protected]>
Thu, 25 Sep 2025 11:25:33 +0000 (13:25 +0200)
In the overview page are all active dhcp leases displayed.
For easier recognition, the listed MAC addresses fo these leases are
resolved to their vendor names.

Signed-off-by: Christian Korber <[email protected]>
modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js
modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status-index.json

index a98906f9fe25a1cd75ec399fe003b80bf70734bd..27e903f2cdfafddbd68f42ef1701bb15d5c5b048 100644 (file)
@@ -11,6 +11,17 @@ var callLuciDHCPLeases = rpc.declare({
        expect: { '': {} }
 });
 
+var callUfpList = rpc.declare({
+       object: 'fingerprint',
+       method: 'fingerprint',
+});
+
+var checkUfpInstalled = rpc.declare({
+       object: 'file',
+       method: 'stat',
+       params: [ 'path' ]
+});
+
 return baseclass.extend({
        title: '',
 
@@ -19,10 +30,17 @@ return baseclass.extend({
 
        load: function() {
                return Promise.all([
-                       callLuciDHCPLeases(),
-                       network.getHostHints(),
-                       L.resolveDefault(uci.load('dhcp'))
-               ]);
+                       checkUfpInstalled('/usr/sbin/ufpd')
+               ]).then(data => {
+                       var promises = [
+                               callLuciDHCPLeases(),
+                               network.getHostHints(),
+                               data[0].type === 'file' ? callUfpList() : null,
+                               L.resolveDefault(uci.load('dhcp'))
+                       ];
+
+                       return Promise.all(promises);
+               });
        },
 
        handleCreateStaticLease: function(lease, ev) {
@@ -64,6 +82,7 @@ return baseclass.extend({
                    leases6 = Array.isArray(data[0].dhcp6_leases) ? data[0].dhcp6_leases : [],
                    machints = data[1].getMACHints(false),
                    hosts = uci.sections('dhcp', 'host'),
+                   macaddr = data[2],
                    isReadonlyView = !L.hasViewPermission();
 
                for (var i = 0; i < hosts.length; i++) {
@@ -94,6 +113,7 @@ return baseclass.extend({
 
                cbi_update_table(table, leases.map(L.bind(function(lease) {
                        var exp, rows;
+                       var vendor;
 
                        if (lease.expires === false)
                                exp = E('em', _('unlimited'));
@@ -110,10 +130,15 @@ return baseclass.extend({
                        else if (lease.hostname)
                                host = lease.hostname;
 
+                       if (macaddr) {
+                               var lowermac = lease.macaddr.toLowerCase();
+                               vendor = macaddr[lowermac].vendor ? macaddr[lowermac].vendor : null;
+                       }
+
                        rows = [
                                host || '-',
                                lease.ipaddr,
-                               lease.macaddr,
+                               vendor ? lease.macaddr + ` (${vendor})` : lease.macaddr,
                                exp
                        ];
 
index 99b4d02b1d44ea5660b2fad8fa5251c1173b540f..3fda23977587e589a21db6be8bff1db53f1563d0 100644 (file)
@@ -33,7 +33,9 @@
                "description": "Grant access to DHCP status display",
                "read": {
                        "ubus": {
-                               "luci-rpc": [ "getDHCPLeases" ]
+                               "luci-rpc": [ "getDHCPLeases" ],
+                               "fingerprint": [ "fingerprint" ],
+                               "file": [ "stat" ]
                        }
                }
        },